<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="pragma" content="no-cache" />
	<link rel="stylesheet" href="/css/style.css" type="text/css"/>
	<script type="text/javascript" src="/js/jquery.js"></script>
	<script type="text/javascript" src="/js/util.js"></script>
</head>
<script type="text/javascript">
//////////////////////////////////////////////////////////////////////
////  email = "wenpin.qian@happyelements.com"                     ////
////  team = "Athene"                                             ////
////  warnings = "This is generated page,Do Not Modify!";         ////
////  tips = "Opera & IE not supported|Chrome & Safari sugguested"////
//////////////////////////////////////////////////////////////////////
window.returnValue=0;

$(document).ready(function() {
listselectors();
});

function addbattle_point() {
	var addbattle_pointUrl = "/battle_point/add/";
	var nameValue = $("#name").val();
	if(!checkString("名字",nameValue,false)) {
		return;
	}
	var nameParam = "name=" + xparseString(nameValue);
		
	var descValue = $("#desc").val();
	if(!checkString("描述",descValue,false)) {
		return;
	}
	var descParam = "desc=" + xparseString(descValue);
		
	var npcIdValue = $("#npcId").val();
	
	var npcIdParam = "npcId=" + npcIdValue;
		
	var campaignIdValue = $("#campaignId").val();
	
	var campaignIdParam = "campaignId=" + campaignIdValue;
		
	var weatherIdsValue = $("#weatherIds").val();
	
	var weatherIdsParam = "weatherIds=" + weatherIdsValue;
		
	var roundMaxValue = $("#roundMax").val();
	if(!checkInteger("最大回合数",roundMaxValue,false)) {
		return;
	}
	var roundMaxParam = "roundMax=" + xparseInt(roundMaxValue);
		
	var leaderDeadValue = $("#leaderDead").val();
	
	var leaderDeadParam = "leaderDead=" + leaderDeadValue;
		
	var roundLimitValue = $("#roundLimit").val();
	
	var roundLimitParam = "roundLimit=" + roundLimitValue;
		
	var leaderValue = $("#leader").val();
	
	var leaderParam = "leader=" + leaderValue;
		
	var roundValue = $("#round").val();
	
	var roundParam = "round=" + roundValue;
		
	var endConditionValue = $("#endCondition").val();
	
	var endConditionParam = "endCondition=" + endConditionValue;
		
	var attackerMaxValue = $("#attackerMax").val();
	if(!checkInteger("参战人数上限",attackerMaxValue,false)) {
		return;
	}
	var attackerMaxParam = "attackerMax=" + xparseInt(attackerMaxValue);
		
	var defenderMaxValue = $("#defenderMax").val();
	if(!checkInteger("防守人数上限",defenderMaxValue,false)) {
		return;
	}
	var defenderMaxParam = "defenderMax=" + xparseInt(defenderMaxValue);
		
	var areaIdValue = $("#areaId").val();
	if(!checkInteger("战场大小",areaIdValue,false)) {
		return;
	}
	var areaIdParam = "areaId=" + xparseInt(areaIdValue);
		
	var dropsValue = $("#drops").val();
	
	var dropsParam = "drops=" + dropsValue;
		
	var energyCostValue = $("#energyCost").val();
	if(!checkInteger("消耗精力点数",energyCostValue,false)) {
		return;
	}
	var energyCostParam = "energyCost=" + xparseInt(energyCostValue);
		
	var passCountValue = $("#passCount").val();
	if(!checkInteger("过关胜利场数",passCountValue,false)) {
		return;
	}
	var passCountParam = "passCount=" + xparseInt(passCountValue);
		
	var difficultyValue = $("#difficulty").val();
	if(!checkInteger("据点难度",difficultyValue,false)) {
		return;
	}
	var difficultyParam = "difficulty=" + xparseInt(difficultyValue);
		
	var starMaxValue = $("#starMax").val();
	if(!checkInteger("最大星级",starMaxValue,false)) {
		return;
	}
	var starMaxParam = "starMax=" + xparseInt(starMaxValue);
		
	var frontBattlePointIdsValue = $("#frontBattlePointIds").val();
	
	var frontBattlePointIdsParam = "frontBattlePointIds=" + frontBattlePointIdsValue;
		
	var afterBattlePointIdsValue = $("#afterBattlePointIds").val();
	
	var afterBattlePointIdsParam = "afterBattlePointIds=" + afterBattlePointIdsValue;
			
	$.ajax({
		   type: "POST",
		   url: addbattle_pointUrl,
		   data:   nameParam +'&'+ descParam +'&'+ npcIdParam +'&'+ campaignIdParam +'&'+ weatherIdsParam +'&'+ roundMaxParam +'&'+ leaderDeadParam +'&'+ roundLimitParam +'&'+ leaderParam +'&'+ roundParam +'&'+ endConditionParam +'&'+ attackerMaxParam +'&'+ defenderMaxParam +'&'+ areaIdParam +'&'+ dropsParam +'&'+ energyCostParam +'&'+ passCountParam +'&'+ difficultyParam +'&'+ starMaxParam +'&'+ frontBattlePointIdsParam +'&'+ afterBattlePointIdsParam ,
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
			       window.returnValue=1;
			       beforeWindowClose();
				   window.close();
			   }else {
				  errDialog(data.message);
			   }
		   }
	});
}

function listselectors() {
var getNPCSelectorUrl = "/special/NPC/getList/";
$.ajax({
		   type: "GET",
		   url: getNPCSelectorUrl,
		   data: "",
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
				   selectnpcId(s2json(data.result));
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
var getCampaignSelectorUrl = "/special/Campaign/getList/";
$.ajax({
		   type: "GET",
		   url: getCampaignSelectorUrl,
		   data: "",
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
				   selectcampaignId(s2json(data.result));
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
}

function selectnpcId(options) {
	var optionHTML = "";
	for(var i in options) {
		optionHTML = optionHTML + "<option value='"+ options[i][0] +"'>" + options[i][1] + "</option>\n";
	}
	$("#npcId").html(optionHTML);
}
function selectcampaignId(options) {
	var optionHTML = "";
	for(var i in options) {
		optionHTML = optionHTML + "<option value='"+ options[i][0] +"'>" + options[i][1] + "</option>\n";
	}
	$("#campaignId").html(optionHTML);
}
function addweatherIds() {
	var weatherIdsstr = $("#weatherIds").val();
	var returnCallback = function(retvalue) {
		$('#weatherIds').val(retvalue);
	}
	openDialog("/pages/core/SimpleArray.html",[1,weatherIdsstr],"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
}
function addleader() {
	var leaderstr = $('#leader').val();
	var returnCallback = function(retvalue) {
		$('#leader').val(retvalue);
	}
	openDialog("/pages/customer/BattleEndCondition.html",leaderstr,"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
}
function addround() {
	var roundstr = $('#round').val();
	var returnCallback = function(retvalue) {
		$('#round').val(retvalue);
	}
	openDialog("/pages/customer/BattleEndCondition.html",roundstr,"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
}
function addendCondition() {
	var endConditionstr = $("#endCondition").val();
	var returnCallback = function(retvalue) {
		$('#endCondition').val(retvalue);
	}
	openDialog("/pages/core/Array.html",["/pages/customer/BattleEndCondition.html",endConditionstr],"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
}
function adddrops() {
	var dropsstr = $("#drops").val();
	var returnCallback = function(retvalue) {
		$('#drops').val(retvalue);
	}
	openDialog("/pages/core/Array.html",["/pages/customer/DropItem.html",dropsstr],"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
}
function addfrontBattlePointIds() {
	var frontBattlePointIdsstr = $("#frontBattlePointIds").val();
	var returnCallback = function(retvalue) {
		$('#frontBattlePointIds').val(retvalue);
	}
	openDialog("/pages/core/SimpleArray.html",[1,frontBattlePointIdsstr],"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
}
function addafterBattlePointIds() {
	var afterBattlePointIdsstr = $("#afterBattlePointIds").val();
	var returnCallback = function(retvalue) {
		$('#afterBattlePointIds').val(retvalue);
	}
	openDialog("/pages/core/SimpleArray.html",[1,afterBattlePointIdsstr],"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
}

function openResource(fieldname,dependfield) {
	var param = "";
	if(dependfield!="") {
		param = $("#" + dependfield).val()
		if(param == null || param == "") {
			alert("你先把【" + $("#lbl_" + dependfield).html() + "】填了再上传");
			return;
		}
	}
	resourceDialog("battle_point",$("#" + fieldname).val(),param,function(result) {
		if(result != undefined && result != "") {
			$("#" + fieldname).val(result);
		}
	});
}

function beforeWindowClose() {
	if(window.returnCallback) {
		window.returnCallback(window.returnValue);
	}
	window.onbeforeunload = null;
	return true;
}

</script>
<body onunload="beforeWindowClose()">
	<div class="addarea">
	<form action="/battle_point/add" method="post">
		<table>
			<tbody>				
					<tr>					<td>
						<label for="name" id="lbl_name">名字</label>
													<input type="text" id="name" name="name" /><span class="tips">[文字]</span>
											</td>
									
										<td>
						<label for="desc" id="lbl_desc">描述</label>
													<input type="text" id="desc" name="desc" /><span class="tips">[文字]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="npcId" id="lbl_npcId">NPC编号</label>
													<select id="npcId" name="npcId">
							</select>
											</td>
									
										<td>
						<label for="campaignId" id="lbl_campaignId">战役点编号</label>
													<select id="campaignId" name="campaignId">
							</select>
											</td>
					</tr>				
					<tr>					<td>
						<label for="weatherIds" id="lbl_weatherIds">天气列表</label>
													<input type="text" id="weatherIds" name="weatherIds" value="[]" disabled/>
							<input type="button" value="..." onclick="addweatherIds()"/>
											</td>
									
										<td>
						<label for="roundMax" id="lbl_roundMax">最大回合数</label>
													<input type="text" id="roundMax" name="roundMax" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="leaderDead" id="lbl_leaderDead">首领死亡结果</label>
																				<select id="leaderDead" name="leaderDead">
								
									<option value="0">无</option>
								
									<option value="1">胜利</option>
								
									<option value="2">失败</option>
								
									<option value="3">平局</option>
															</select>
											</td>
									
										<td>
						<label for="roundLimit" id="lbl_roundLimit">回合上限值</label>
																				<select id="roundLimit" name="roundLimit">
								
									<option value="0">无</option>
								
									<option value="1">胜利</option>
								
									<option value="2">失败</option>
								
									<option value="3">平局</option>
															</select>
											</td>
					</tr>				
					<tr>					<td>
						<label for="leader" id="lbl_leader">首领</label>
													<input type="text" id="leader" name="leader" value="{}" disabled/>
							<input type="button" value="..." onclick="addleader()"/>
											</td>
									
										<td>
						<label for="round" id="lbl_round">回合</label>
													<input type="text" id="round" name="round" value="{}" disabled/>
							<input type="button" value="..." onclick="addround()"/>
											</td>
					</tr>				
					<tr>					<td>
						<label for="endCondition" id="lbl_endCondition">结束条件</label>
													<input type="text" id="endCondition" name="endCondition" value="[]" disabled/>
							<input type="button" value="..." onclick="addendCondition()"/>
											</td>
									
										<td>
						<label for="attackerMax" id="lbl_attackerMax">参战人数上限</label>
													<input type="text" id="attackerMax" name="attackerMax" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="defenderMax" id="lbl_defenderMax">防守人数上限</label>
													<input type="text" id="defenderMax" name="defenderMax" /><span class="tips">[整数]</span>
											</td>
									
										<td>
						<label for="areaId" id="lbl_areaId">战场大小</label>
													<input type="text" id="areaId" name="areaId" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="drops" id="lbl_drops">掉落</label>
													<input type="text" id="drops" name="drops" value="[]" disabled/>
							<input type="button" value="..." onclick="adddrops()"/>
											</td>
									
										<td>
						<label for="energyCost" id="lbl_energyCost">消耗精力点数</label>
													<input type="text" id="energyCost" name="energyCost" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="passCount" id="lbl_passCount">过关胜利场数</label>
													<input type="text" id="passCount" name="passCount" /><span class="tips">[整数]</span>
											</td>
									
										<td>
						<label for="difficulty" id="lbl_difficulty">据点难度</label>
													<input type="text" id="difficulty" name="difficulty" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="starMax" id="lbl_starMax">最大星级</label>
													<input type="text" id="starMax" name="starMax" /><span class="tips">[整数]</span>
											</td>
									
										<td>
						<label for="frontBattlePointIds" id="lbl_frontBattlePointIds">前置战点列表</label>
													<input type="text" id="frontBattlePointIds" name="frontBattlePointIds" value="[]" disabled/>
							<input type="button" value="..." onclick="addfrontBattlePointIds()"/>
											</td>
					</tr>				
					<tr>					<td>
						<label for="afterBattlePointIds" id="lbl_afterBattlePointIds">后置战点列表</label>
													<input type="text" id="afterBattlePointIds" name="afterBattlePointIds" value="[]" disabled/>
							<input type="button" value="..." onclick="addafterBattlePointIds()"/>
											</td>
												</tbody>
		</table>
		<input type="button" onclick="addbattle_point()" value="添加"/>
	</form>
	</div>
</body>